package com.studentgrowth.service.auth.impl;

import com.studentgrowth.service.auth.SmsService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;


@Service
public class SmsServiceImpl implements com.studentgrowth.service.sms.SmsService {

    private static final Logger log = LoggerFactory.getLogger(SmsServiceImpl.class);

    @Override
    public void sendVerificationCode(String phoneNumber, String code) {
        // 暂时只打印日志，等待阿里云短信服务申请完成
        log.info("模拟发送验证码: phoneNumber={}, code={}", phoneNumber, code);

            /*
            // 阿里云短信发送代码，暂时注释
            try {
                DefaultProfile profile = DefaultProfile.getProfile(
                    "cn-hangzhou",
                    accessKeyId,
                    accessKeySecret
                );
                IAcsClient client = new DefaultAcsClient(profile);

                CommonRequest request = new CommonRequest();
                request.setSysMethod(MethodType.POST);
                request.setSysDomain("dysmsapi.aliyuncs.com");
                request.setSysVersion("2017-05-25");
                request.setSysAction("SendSms");
                request.putQueryParameter("PhoneNumbers", phoneNumber);
                request.putQueryParameter("SignName", signName);
                request.putQueryParameter("TemplateCode", templateCode);
                request.putQueryParameter("TemplateParam", "{\"code\":\"" + code + "\"}");

                client.getCommonResponse(request);
            } catch (Exception e) {
                log.error("发送短信失败", e);
                throw new RuntimeException("发送短信失败");
            }
            */
    }
}
